<?php 

Class ModuleSignupResult extends CmsCustomModule {
	
	private function getBitrate(){
		return array(
			rand(100, 10000),
			rand(100, 10000),
			rand(100, 10000),
		);
	}
	private function getItemHTML($regin, $sub='', $country=''){
		if(!$country && $sub && !in_array(strtolower($regin), array('americas', 'africa'))){
			return '';
		}
		$class = '';
		if(!$country && !$sub){
			$class = ' class="weight"';
		}
		$name = $regin ? $regin : '';
		$name = $sub ? '&nbsp;&nbsp;'.$sub : $name;
		//$name = $country ? '&nbsp;&nbsp;&nbsp;&nbsp;'.$country : $name;
		$name = $country ? $country : $name;
		
		return <<<HTML
  <tr{$class}>
	<td class="txtleft"><p>{$name}</p></td>
	<td>999,999</td>
	<td>999,999</td>
	<td>999,999</td>
	<td>999,999</td>
	<td>999,999</td>
	<td>999,999</td>
	<td>999,999</td>
	<td>999,999</td>
	<td>999,999</td>
	<td>999,999</td>
  </tr>
HTML;
	}
    protected function __renderHead()
    {
		$filters = array('dateby', 'startmonth', 'startyear', 'endmonth', 'endyear', 'startdate', 'enddate', 'country');
		foreach($_GET as $k=>$v){
			if(in_array($k, $filters)){
				$$k = $v;
			}
		}
		$startmonth = str_pad($startmonth, 2, 0, STR_PAD_LEFT);
		$endmonth = str_pad($endmonth, 2, 0, STR_PAD_LEFT);
		$curr_datetime = date("Y-m-d H:i:s");
		
		$str_date = '';
		if($dateby == 'date'){
			$str_date = "{$startdate} - {$enddate}";
		}else{
			$str_date = "{$startyear} - {$startmonth} to {$endyear} - {$endmonth}";
		}
		
		$str_country = transCountry($country);
		
		$country = json_decode($country);
		$list_html = '';
		foreach($country as $k=>$item){
			if(is_object($item)){
				$list_html .= $this->getItemHTML($k);
				foreach($item as $k2=>$item2){
					//$list_html .= $this->getItemHTML($k, $k2);
					foreach($item2 as $k3=>$item3){
						//$k3 = getStatsClass::getCountryByAll($k, $k2, $item3);
						$list_html .= $this->getItemHTML($k, $k2, "{$item3} ({$k3})");
					}
				}
			}else{
				$list_html .= $this->getItemHTML($k);
			}
		}
		
		$dateby = ucwords( strtolower($dateby));
		$remarkhtml = $this->getRemark();
		
		$this->contents = <<<HTML
	<div id="result" class="signup_result">
		<div class="hd">
			<div class="utility">
				<a href="#" class="print">Print</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				Export to <a href="#">HTML</a>
			</div>
			<hr />
			<h1>Sign-up Diagnostic Report</h1>
			<div class="time">{$curr_datetime}</div><br />
			<div><b>By {$dateby}:</b> {$str_date}</div>
			<table border="0" class="nob"><tr><td valign="top" width="100"><b class="tit">Region/Country:</b>&nbsp;</td><td>{$str_country}</td></tr></table>
			<div>&nbsp;</div>
			{$remarkhtml}
		</div>
		<div class="bd">
		<h2>Region & Country Group </h2>
<table width="100%" border="0" class="tb1">
  <tr>
	<td width="22%" rowspan="2" bgcolor="#EEE" class="txtleft"><strong>Region/ Country</strong></td>
	<td colspan="2" bgcolor="#EEE"><div align="center"><strong>Free Membership</strong></div></td>
	<td colspan="3" bgcolor="#EEE"><div align="center"><strong>Facebook</strong></div></td>
	<td colspan="5" bgcolor="#EEE"><div align="center"><strong>Premium</strong></div></td>
  </tr>
  <tr>
	<td bgcolor="#EEE">FM_S1</td>
	<td bgcolor="#EEE">FM_A</td>
	<td bgcolor="#EEE">FB_S1</td>
	<td bgcolor="#EEE">FB_S2</td>
	<td bgcolor="#EEE">FB_A</td>
	<td bgcolor="#EEE">P_S1</td>
	<td bgcolor="#EEE">P_S2</td>
	<td bgcolor="#EEE">P_S3</td>
	<td bgcolor="#EEE">P_S4</td>
	<td bgcolor="#EEE">P_A</td>
  </tr>
  {$list_html}
  
  <tr class="weight">
	<td class="txtleft">Total</td>
	<td>999,999</td>
	<td>999,999</td>
	<td>999,999</td>
	<td>999,999</td>
	<td>999,999</td>
	<td>999,999</td>
	<td>999,999</td>
	<td>999,999</td>
	<td>999,999</td>
	<td>999,999</td>
  </tr>
</table>
		</div>
	</div>
HTML;
    }
	private function getRemark(){
return <<<HTML

			<table class="nob">
				<colgroup><col width="30"/><col width="" /><col width="30"/><col width=""/></colgroup>
				<tr><td colspan="4"><b>Remark</b>:</td></tr>
				<tr>
					<td>FM_S1: </td><td> Free Membership Registration - Fill In The Form</td>
					<td>P_S1: </td><td> Premium - Select Plan</td>
				</tr>
				<tr>
					<td>FM_A: </td><td> Free Membership - Activate Complete</td>
					<td>P_S2: </td><td> Premium - Personal Details</td>
				</tr>
				<tr>
					<td>FB_S1: </td><td> Facebook - Fill In The Form</td>
					<td>P_S3: </td><td> Premium - Payment</td>
				</tr>
				<tr>
					<td>FB_S2: </td><td> Facebook - Personal Details</td>
					<td>P_S4: </td><td> Premium - Confirmation</td>
				</tr>
				<tr>
					<td>FB_A: </td><td> Facebook - Activate Complete</td>
					<td>P_A: </td><td> Activate Complete</td>
				</tr>
			</table>
HTML;
	/*
	
			<div><b>Remark</b>:<br />
FM_S1: Free Membership Registration - Fill In The Form<br />
FM_A: Free Membership - Activate Complete<br />
FB_S1: Facebook - Fill In The Form<br />
FB_S2: Facebook - Personal Details<br />
FB_A: Facebook - Activate Complete <br />
P_S1: Premium - Select Plan<br />
P_S2: Premium - Personal Details<br />
P_S3: Premium - Payment<br />
P_S4: Premium - Confirmation<br />
P_A: Activate Complete
			</div>
	*/
	
	}
}
?>